package com.example.springboot.mapper;


import com.example.springboot.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
//数据库查询接口
public interface Usermapper {

    //查询全部
    @Select("select * from user")
    List<User> finAll();
//zhuce
    @Insert("INSERT into user(username,password,email,phone,address) VALUES (#{username},"+
            "#{password},#{email},#{phone},#{address})")
    int insert(User user);
//gengxin
    @Update("update user set username = #{username},password = #{password} where id=#{id}")
    int update(User user);

    //登录
    @Select("SELECT password FROM user WHERE username = #{username}")
    String getPasswordByUsername(String username);
}
